<template>
	<!--综合税费申报-->
	<view class="yhsfsb">
		<view class="title">
			<text>印花税费申报</text>
		</view>
		<view class="sbLists">
			<uni-group class="dqjItem">
				<view class="sbtitle">
					<view>出租屋地址：{{yhsbData.address}}</view>
				</view>
				<view v-if="zlJqJudge">
					<view class="item">
						<view class="name">租赁编号</view>
						<view class="con">{{yhsbData.rentCode}}</view>
					</view>
					<view class="item">
						<view class="name">纳税人识别号</view>
						<view class="con">{{yhsbData.shxydm}}</view>
					</view>
					<view class="item">
						<view class="name">纳税人名称</view>
						<view class="con">{{yhsbData.nsrmc}}</view>
					</view>
					<view class="item">
						<view class="name">{{fsCity?'租赁月份起止':'出租起止时间'}}</view>
						<view class="con">
							<text>{{yhsbData.startDate}}</text>
							<text>至</text>
							<text>{{yhsbData.endDate}}</text>
						</view>
					</view>
					<view class="item">
						<view class="name">合同签约时间</view>
						<view class="con">{{yhsbData.contractBuildDate}}</view>
					</view>
					<view class="item">
						<view class="name">合同总租金</view>
						<view class="con">{{yhsbData.contractRent}}</view>
					</view>
					<view class="item">
						<view class="name  hj">所占比例</view>
						<view class="con"><text>{{parseFloat(yhsbData.szfe)*100||""}}</text><text>%</text></view>
					</view>
				</view>
			</uni-group>
		</view>
		<view class="zlzkorxs">
			<view class="zlxxZs" v-show="!zlJqJudge" @click="bindZs">
				<view>租赁详情展开</view>
				<uni-icons custom-prefix="custom-icon" type="bottom" size="30" class="cg"></uni-icons>
			</view>
			<view class="zlxxZs" v-show="zlJqJudge" @click="bindZs">
				<view>租赁详情收起</view>
				<uni-icons custom-prefix="custom-icon" type="top" size="30" class="cg"></uni-icons>
			</view>
		</view>
		<view class="zlform">
			<view class="btn">
				<button type="primary" size="mini" @click="jssk">计算税款</button>
			</view>
		</view>
		<view class="sesj">
			<view class="seTitle">
				<view class="lsbt"></view>
				<text>应纳税额</text>
			</view>
			<view class="seItem" v-for="(item,index) in czwSbZhMxList" :key="index">
				<view>
					<view class="itemTitle">
						{{item.houseNote}}（元）
					</view>
					<view class="itemTip">
						(印花税2019年之前按千分之一计征，2019年以后按万分之五计征)
					</view>
				</view>
				<view class="itemMny">{{item.ynse}}</view>
			</view>

		</view>
		<view class="sesj">
			<view class="seTitle">
				<view class="lsbt"></view>
				<text>减免税额</text>
			</view>
			<view class="seItem">
				<view>
					<view class="itemTitle">
						减免税额（元）
					</view>
				</view>
				<view v-if="!fsCity" class="itemMny">{{jsseData.jmse}}</view>
				<view v-else class="itemMny">{{jsseData?Math.round(Number(jsseData.jmse+jsseData.phjmse)*100)/100:""}}</view>
			</view>
		</view>
		<view class="sesj">
			<view class="seTitle">
				<view class="lsbt"></view>
				<text>已缴税额</text>
			</view>
			<view class="seItem">
				<view>
					<view class="itemTitle">
						已缴税额（元）
					</view>
				</view>
				<view class="itemMny">{{jsseData.yjse}}</view>
			</view>
		</view>
		<view class="sesj">
			<view class="seTitle">
				<view class="lsbt"></view>
				<text>滞纳金</text>
			</view>
			<view class="seItem">
				<view>
					<view class="itemTitle">
						滞纳金（元）
					</view>
					<view class="itemTip">
						(根据《中华人民共和国税收征收管理法》，从滞纳税款之日起，按日加收滞纳税款万分之五的滞纳金。本申报显示的滞纳金金额计算截至{{$commonCzwjs.date("","年月日")}}。若您未于当日清缴税费，滞纳金仍将相应增加，以实际清缴时的金额为准。)
					</view>
				</view>

				<view class="itemMny">{{jsseData.znj}}</view>
			</view>
		</view>
		<view class="sesj">
			<view class="seTitle">
				<view class="lsbt"></view>
				<text>当前合计</text>
			</view>
			<view class="seItem">
				<view>
					<view class="itemTip">
						(合计金额=应纳税额-减免税额-已缴税额+滞纳金)
					</view>
				</view>
				<view class="itemMny">{{((jsseData.znj+jsseData.ybtse)||0).toFixed(2)}}</view>
			</view>
		</view>
		<view class="yhsYjjsyj" v-if="yhsbData.yhsYjjsyj&&yhsbData.yhsYjjsyj!=='0'">
			说明：合同总租金中已完税的租金金额为：<span>{{yhsbData.yhsYjjsyj}}</span>元</view>
		<view class="sbBtn btn">
			<button type="primary" size="mini" @click="ksSb">申报</button>
			<button type="default" plain="true" size="mini" @click="goBack">返回修改</button>
		</view>
	</view>
</template>

<script>
	import {
		getPreSbInfo,
		calSbxx,
		saveSbxx
	} from "@/utils/common-api.js"
	import commonTools from "@/utils/common-tools.js";
	let xzh=commonTools.getXzq()
	export default {
		data() {
			return {
				yhsbData: "",
				czwSbZhMxList: [],
				jsseData: "",
				sbId: "", //申报id
				zlJqJudge:true,
				fsCity:xzh.xzqhszDm=="440600"?"true":false
			}
		},
		onLoad(e) {
			// console.log(e) 
			this.yhssbForm = JSON.parse(e.yhssbForm)
			this.handleSearch()
		},
		methods: {
			async handleSearch() {
				this.yhssbForm.isNeedRentMx = "1"
				let res = await getPreSbInfo(this.yhssbForm)
				// console.log(res)
				if (res.head.errorCode == "0") {
					this.yhsbData = res.body
				} else if (res.head.errorCode != "0") {
					uni.showToast({
						title: '数据请求失败',
						icon: 'error',
						duration: 3000
					})
				}
			},
			// 计算税款
			async jssk() {
				let datas = this.yhssbForm
				let params = {
					nsrId: datas.nsrId,
					rentId: datas.rentId,
					isCzr: datas.isCzr,
					sbqd:datas.sbqd,
					sblx: "02",
					xzqhDm:datas.sjXzqhsjDm
				}
				let res = await calSbxx(params)
				// console.log(res)
				if (res.head.errorCode == "0") {
					this.jsseData = res.body
					this.czwSbZhMxList = res.body.czwSbZhMxList
					this.sbId = res.body.id
				} else if (res.head.errorCode != "0") {
					uni.showToast({
						title: res.head.errorMsg,
						icon: 'error',
						duration: 3000
					})
				}
			},
			// 开始申报
			ksSb() {
				// 判断是否已计算税款
				if (!this.jsseData) {
					uni.showToast({
						title: '请计算税款',
						icon: 'error',
					})
					return
				}
				uni.showModal({
					title: '提示',
					content: '请确认是否提交申报',
					confirmColor: '#007aff', //确定字体颜色
					buttonText: '确定',
					success: async (res) => {
						if (res.confirm) {
							let res = await saveSbxx({
								id: this.sbId
							})
							// console.log(res)
							if (res.head.errorCode == "0") {
								uni.redirectTo({
									url: "/pages/sfsb/sbResult?result=success&sbxx=" + JSON.stringify({
										address: this.yhsbData.address,
										nsrlx: this.yhssbForm.sbqd
									})
								});
							} else if (res.head.errorCode != "0") {
								uni.redirectTo({
									url: "/pages/sfsb/sbResult?result=fail"
								});
							}
						} else {
							console.log("")
						}
					}
				});
			},
			// 返回修改
			goBack() {
				this.$commonCzwjs.goPage({
					url: "/pages/sfsb/sbzlxxcx",
				})
			},
			// 点击展开或收起
			bindZs() {
				// console.log(this.zlJqJudge)
				if (this.zlJqJudge) {
					this.zlJqJudge = false
				} else {
					this.zlJqJudge = true
				}
			
			}
		}
	}
</script>

<style>
	.yhsfsb {}

	.title {
		width: 100%;
		height: 80rpx;
		background: #3171d5;
		text-align: center;
		line-height: 80rpx;
		color: white;
	}

	.sbLists {
		box-sizing: border-box;
		width: 100%;
		font-weight: bold;
		font-size: 26rpx;
	}

	.dqjItem {
		background: #ffffff;
		border: 2rpx solid #e7e7e7;
	}

	.sbtitle {
		padding: 10rpx 20rpx;
		border-bottom: 5rpx solid #3171d5;
		color: #3171d5;
	    word-wrap: break-word;

	}

	.sbLists .qjk {
		margin-right: 20rpx;
	}

	::v-deep .uni-group .uni-group__content {
		padding: 0;
	}

	.uni-group__content {
		padding: 0;
	}

	.sbLists .item {
		height: 80rpx;
		line-height: 80rpx;
		display: flex;
		border-bottom: 2rpx solid #66666640;
	}

	.sbLists .item:last-child {
		border-bottom: 0rpx solid #66666640;
	}

	.sbLists .item .name {
		width: 180rpx;
		color: #66666699;
		text-align: left;
		margin-right: 10rpx;
		padding-left: 20rpx;

	}

	.sbLists .item .con {
		color: #222222;
		text-align: left;
	}

	.sbLists .item .hj {
		color: #222222;
	}

	.zlform {
		background: #ffffff;
		padding: 20rpx;
	}

	.btn {
		text-align: center;
	}

	.btn uni-button {
		width: 240rpx;
		margin: 0 20rpx;
		height: 70rpx;
		line-height: 70rpx;
	}

	.sesj {
		margin-top: 10rpx;
		background: #ffffff;
	}

	.sesj>.seTitle {
		border-bottom: 2rpx #e5e5e5 solid;
		font-weight: bold;
		font-size: 28rpx;
		position: relative;
		padding: 10rpx 20rpx;
	}

	.seTitle .lsbt {
		position: absolute;
		left: 10rpx;
		top: 50%;
		transform: translateY(-50%);
		width: 8rpx;
		height: 30rpx;
		background: #1198d3;
		border-radius: 4rpx;
	}

	.seItem {
		padding: 20rpx;
		display: flex;
		justify-content: space-between;
		border-bottom: 2rpx #e5e5e5 solid;
	}

	.itemTitle,
	.itemMny {
		font-size: 28rpx;
	}

	.itemMny {
		min-width: 150rpx;
		text-align: center;
		color: red;
		font-weight: bold;
		word-wrap: break-word;
		word-break: break-all;
	}

	.itemTip {
		font-size: 20rpx;
		color: #666666;
	}

	.sbBtn {
		padding: 20rpx;
		background: #ffffff;
	}

	.yhsYjjsyj {
		padding: 20rpx;
		font-size: 20rpx;
		color: black;
		background: #ffffff;
	}

	.yhsYjjsyj span {
		font-size: 30rpx;
		color: #3171d5;
	}
	.zlzkorxs {
		display: flex;
		justify-content: center;
		background: #ffffff;
		padding: 10rpx 0;
	}
	
	.zlxxZs {
		font-size: 28rpx !important;
		display: flex;
		justify-content: center;
		align-items: center;
		color: #3171d5;
		width: 240rpx;
		border: 2rpx solid #3171d5;
		padding: 5rpx;
		border-radius: 6rpx;
	}
	.uniui-bottom {
		font-size: 28rpx !important;
		color: #3171d5 !important;
		font-weight: bold;
	}
	
	.uniui-top {
		font-size: 28rpx !important;
		color: #3171d5 !important;
		font-weight: bold;
	}
</style>